if(!lanYun){var lanYun = {ver:1.2}};

lanYun.isTest = 0;//测试环境1  正式环境0
lanYun.apiUrl = 'http://app.tianhongmuchen.com/api/';
lanYun.jpushTag = "usera";

if(lanYun.isTest == 1){
	//lanYun.apiUrl = 'http://192.168.31.31/api/';
	lanYun.apiUrl = 'http://hs2.wei-a.com/api/';
	lanYun.jpushTag = "useratest";
}
lanYun.loadType ='icon';
var onShow = function(){};
!(function(HH) {
	HH.loadingMsg = '<span>加载中···</span>';
	HH.loadingNoMsg = '- 已经到底部了 -';
	HH.ajaxSta=0,HH.ajaxPageSta=0,HH.page=1,HH.timeout=5,HH.wait=60,HH.href = window.location.href;
	HH.getAppInfo = function() {
		var time = new Date().getTime();
		var info = {appId:'A10000001', devId:'api.deviceId',time:time};
		//info.userAgent = navigator.userAgent;
		//info.Param = md5(navigator.userAgent + info.time);
		if(isApp) {
			info = {
				jsVer:HH.ver,lan:HH.lan,sysVer:api.systemVersion,appVer:api.appVersion,devModel:api.deviceModel,devId:api.deviceId,
				appId:api.appId,osType:api.systemType,time:time,dev:'app'
			};
		}
		//info.sign = md5(info.appId+(info.time-HH.ver)+info.devId);
		return info;
	};
	HH.openWin = function(name , Param){
		var animation = [
			{type:'movein',subType:"from_right",duration: 300}, //从右覆盖
			{type:'push',subType:"from_right",duration: 300}, //左右推
			{type:'movein',subType:"from_bottom",duration: 300} //从下覆盖
		];
		if(!Param) Param = {frameParam:{}};
		if(!Param.frameParam) Param.frameParam = {};
		var _win = "win.html";
		var _id = name +'_win';
		Param.name = name;
		Param.ani = Param.ani ? Param.ani : 0;
		Param.backlock = Param.backlock ? true : false;
		Param.softInputMode = Param.softInputMode ? Param.softInputMode : 'auto';
		if(Param.winid) _id = Param.winid;
		if(Param.frameParam['id']) _id = Param.name + Param.frameParam['id'];
		if(Param.win && Param.win != 'none' && Param.win != 'mini') _win = Param.win+'.html';
		if(Param.id) _id += new Date().getTime();
		var pid = Param.name.split('/');Param.furl = pid[pid.length-1];
		if(!isApp){
			var wurl = Param.name;
			if(Param.name.indexOf('.html') == -1) wurl = Param.name +'/'+Param.furl+'.html';
			window.location.href = HH.wapUrl + wurl;
			return;
		}
		Param._url = 'widget://html/'+Param.name;
		if(Param.name.indexOf('.html') == -1){
			Param._url += '/'+Param.furl+'.html';
		}
		if(Param.url) Param._url = Param.url;
		//log(Param);
		var sysVer = parseFloat(api.systemVersion);
		var isNew = 0;
		// if(api.systemType=='android'){
		// 	if(sysVer < 7){
		// 		isNew = 0;
		// 	}
		// 	if(Param.isold){
		// 		isNew = 0;
		// 	}
		// }
		if(isNew) {
			//console.log('11----------'+ Param.backlock);
			//console.log(JSON.stringify(Param)); //navitembtn
			if(Param.win !="none"){
				Param.listener = true;
			}
			api.openTabLayout({
				bgColor : Param.winBg ? 'widget://image/main/'+ Param.winBg : '#FFF',
				name: _id,softInputMode:Param.softInputMode,slidBackEnabled:Param.backlock,
				url: Param._url,
				title: Param.title,
				animation:animation[Param.ani],
				bounces:false, pageParam: Param.frameParam,
				hideNavigationBar: Param.win == 'none' ? true:false, //Param.win != 'none'
				navigationBar: {
					background: '#FFF',
					color: '#222',
					leftButtons: [{
						iconPath: 'widget://image/main/back.png'
					}],
					//{text:'按钮',color:'#222',fontSize:16,iconPath:'widget://image/back.png'}
					rightButtons:Param.menu
				}
			});

		}else{
			api.openWin({
				bgColor : Param.winBg ? 'widget://image/main/'+ Param.winBg : '#FFF',
				name: _id,softInputMode:Param.softInputMode,slidBackEnabled:'true',
				url:'widget://html/win/'+_win, bounces:false, pageParam: Param, vScrollBarEnabled : false, animation:animation[Param.ani]
			});
		}

	};
	HH.openFrame = function(name , Param , callBack) {
		var animation = [
			{type:'none'}, //无
			{type:'movein',subType:"from_right",duration: 300}, //从右覆盖
			{type:'movein',subType:"from_bottom",duration: 300} //从下覆盖
		];
		var wurl = name;
		if(name.indexOf('.html') == -1) wurl = name +'.html';
		Param.ani = Param.ani ? Param.ani : 0;
		Param.topframeName = api.frameName;
		api.openFrame({
            name: name,
            url: 'widget://html/'+ wurl,
			bgColor:'rgba(0,0,0,0)',
			animation:animation[Param.ani],
            rect: {x: 0,y: 0,w: 'auto',h:'auto'},
            pageParam:Param
        });
		if(typeof(callBack) === 'function') {
			window.lyFrameCallBack = callBack;
		}
	};

	HH.FrameCallBack = function(name,data){
		api.execScript({frameName:name, script: 'lyFrameCallBack('+JSON.stringify(data)+')'});
	};

	HH.openClick = function (tis, param) {
		var dst = tis.dataset;
		if(param) HH.extend(dst, param);
		var _awin = dst.win ? dst.win:'';
		//console.log(JSON.stringify(dst));
		HH.openWin(dst.url, {
			win:_awin,
			isold:param.isold,
			ani:param.ani?param.ani:0,
			title : dst.title,
			frameParam : dst,
		});
	};

	//异步 ajax
	HH.ajax = function(parm, successCall, ErrorCallBack) {

		parm.timeout = parm.timeout ? parm.timeout : HH.timeout;
		var url = HH.apiUrl + parm.url;
		if(parm.get) {
			url += '?'+HH.arrToUrlStr(parm.get);
		}
		//console.log(url);
		//HH.debug && console.log(url);
		//HH.debug && console.log(JSON.stringify(parm));
		var ajaxParm = {
			method: parm.method || "POST", url: url, timeout: parm.timeout,
			dataType:"json",
			headers: {
				"Content-Type":"application/json",
				"Content-Info": JSON.stringify(HH.getAppInfo()),
				"Content-Typek": HH.getToken()
			}
		};
		var successFun = function(ret) {
			//console.log(JSON.stringify(ret)+'--'+HH.href);
			if(ret.errcode == 110){
				HH.loginOut();
				HH.ajaxPageSta = 0;
				isApp && api.execScript({name: 'root',script:'needLoginCall('+JSON.stringify(ret)+');'});
				successCall && successCall(ret);
				return false;
			}
			if(ret.needupdate==1){
				isApp && api.execScript({name: 'root',script:'needUpdateCall('+JSON.stringify(ret.updateData)+');'});
			}
			successCall && successCall(ret);
		};
		var errorFun = function(err,msg) {
			HH.debug && console.log(JSON.stringify(err)+'--'+HH.href);
			err.href = HH.href;
			HH.ajaxSta = 0;
			isApp && api.execScript({name: 'root',script:'errorCallBack('+JSON.stringify(err)+');'});
			ErrorCallBack && ErrorCallBack(err);
		};
		if(parm.loading){
			//默认加载框
			//HH.showProgress({mask:'rgba(0,0,0, 0.1)'});
			var load = parm.loading ? 1 : 0;
			if(parm.loading == 2){
				load = 2;
			}
			HH.showProgress({type:load});
		}
		var connectionType = api.connectionType;
		if(connectionType == "none") {
			api.refreshHeaderLoadDone();
			HH.ajaxSta = 0;
			isApp && api.execScript({name: 'root',script:'needWifiCallBack('+JSON.stringify(ajaxParm)+');'});
			ErrorCallBack && ErrorCallBack({ statusCode:10});
			return false;
		}
		if(parm.body) ajaxParm.data = { body:JSON.stringify(parm.body)};
		//console.log(JSON.stringify(ajaxParm));
		api.ajax( ajaxParm , function(ret,err) {
			HH.hideProgress();
			api.refreshHeaderLoadDone();
			if (ret) {
				successFun(ret)
			} else {
				errorFun(err);
			}
		});

	};

	HH.arrToUrlStr = function(param) {
		if(!param) return '';
		var paramStr = '';
		for (var i in param) {
			paramStr += i+'='+encodeURIComponent(param[i])+'&';
		}
		return paramStr.substring(0, paramStr.length - 1);
	};
	//设置倒计时
	HH.setWait = function(tis) {
		var el = $(tis);
		if(HH.wait == 0) {
			el.removeClass("on");
			el.html('获取验证码');
			clearTimeout(HH.timeout);
			HH.rmStorage('wait');
			HH.wait = 60;
		}else {
			el.addClass("on");
			el.html(HH.wait+"s");
			HH.wait--;
			HH.setStorage('wait', HH.wait);
			HH.timeout = setTimeout(function() {
				HH.setWait(tis);
			},1000);
		}
	};
	/*判断是否需要登录*/
	HH.isLogin = function() {
		//return false;
		if(!HH.getToken()) {
			return false;
		}

		if(!HH.getUdata()){
			return false;
		}
		return true;
	};

	HH.openLogin = function (back) {
		HH.openWin('login', {
			//win:'win',
			border:'1',
			from:'login',
			backlock:back,ani:0,
			title:'',frameParam : {},
		});
	};
	// token
	HH.getToken = function() {
		var token = HH.getStorage('token');
		if(!token){
			return HH.debugtoken;
		}
		return token;
	};
	//获取本地用户信息
	HH.getUdata = function() {
		HH.uData = HH.getStorage('UserData');
		if(!HH.uData){
			return null;
		}
		return HH.uData;
	};
	/*登录成功*/
	HH.loginOk = function(udata, send){
		HH.setStorage('token', udata.access_token);
		HH.setStorage('UserData', udata);
		if(!send){
			api.execScript({
				name: 'root',
				script: 'loginCallback('+JSON.stringify(udata)+');'
			});
		}
	};
	/*更新用户信息*/
	HH.updateUdata = function(udata, send){
		HH.setStorage('UserData', udata);
		if(send == 1){
			api.execScript({name: 'root',script: 'updateUdataback();'});
		}
	};
	/*退出登录*/
	HH.loginOut = function(send){
		HH.rmStorage('UserData');
		HH.rmStorage('token');
		if(send == 1){
			api.execScript({name:'root',script:'loginOutCallback();'});
		}
	};
	HH.event = function (type) {
		isApp && api.execScript({name:'root',script:'listenerEvent("'+type+'");'});
	};

})(lanYun);

!(function(HH) {

	HH.newVue = function(id, param, callBack,created,updated) {
		var cahceData = HH.getStorage(window.location.pathname);
		if(HH.isNull(cahceData)) cahceData = {listData:[]};
		var data = {noData:null,loadingMsg:'',Pdata:cahceData};
		if(typeof(param) == 'function') {
			callBack = param;
		}else{
			HH.extend(data,param);
		}
		//console.log(JSON.stringify(data));
		HH.vue = new Vue({ el:id,
			data:data,
			created:callBack.created,
			mounted:function(){
				var data = JSON.parse(JSON.stringify(this.$data));
				callBack(data);
			},
			updated:callBack.updated
		});
	};

	HH.getVueData = function( options , successFun) {
		if(HH.ajaxPageSta==1) return;HH.ajaxPageSta = 1;
		if(HH.page>=2 && !HH.isNull(HH.vue)){
			HH.vue.loadingMsg = HH.loadingMsg;
		}
		this.ajax( options , function(ret) {
			if(HH.page == 1){
				if(options.cache){
					HH.setStorage(window.location.pathname , ret.data);
				}else{
					HH.rmStorage(window.location.pathname);
				}
				if(!ret.data || ret.data.length <= 0){
					HH.vue.noData = '暂无数据..';
				}else{
					HH.vue.noData = null;
					if(ret.data.listData && ret.data.listData.length <= 0){
						HH.vue.noData = '暂无数据..';
					}
					HH.vue.loadingMsg = null;
					HH.vue.Pdata = JSON.parse(JSON.stringify(ret.data));
				}
			}else{
				if(HH.isNull(ret.data.listData) || ret.data.listData.length <= 0) {
					HH.vue.loadingMsg = HH.loadingNoMsg;
					return;
				}
				var tt = options.listid ? options.listid : 'listData';
				HH.vue.Pdata[tt] = HH.vue.Pdata[tt].concat(ret.data.listData);
			}
			HH.vue.$nextTick(function () {
				successFun && successFun(ret);
				isApp && api.parseTapmode();
			});
			HH.page++;HH.ajaxPageSta = 0;
		},function(e){
			setTimeout(function() {
				HH.ajaxPageSta = 0;
			}, 1000);
		});
	};

	HH.getVueData2 = function( options , successFun) {
		if(HH.ajaxPageSta==1) return;HH.ajaxPageSta = 1;
		if(HH.page>=2 && !HH.isNull(HH.vue)){
			HH.vue.loadingMsg = HH.loadingMsg;
		}
		this.ajax( options , function(ret) {
			var tt = options.listid ? options.listid : 'listData';
			if(HH.page == 1){
				if(!ret.data || ret.data.length <= 0){
					HH.vue.noData = '暂无数据..';
				}else{
					HH.vue.noData = null;
					if(ret.data.listData && ret.data.listData.length <= 0){
						HH.vue.noData = '暂无数据..';
					}
					HH.vue.loadingMsg = null;
					HH.vue.Pdata[tt] = ret.data.listData;
				}
			}else{
				if(HH.isNull(ret.data.listData) || ret.data.listData.length <= 0) {
					HH.vue.loadingMsg = HH.loadingNoMsg;
					return;
				}
				HH.vue.Pdata[tt] = HH.vue.Pdata[tt].concat(ret.data.listData);
			}
			HH.vue.$nextTick(function () {
				successFun && successFun(ret);
				isApp && api.parseTapmode();
			});
			HH.page++;HH.ajaxPageSta = 0;
		},function(e){
			setTimeout(function() {
				HH.ajaxPageSta = 0;
			}, 1000);
		});
	};

	HH.post = function (url,data,callback, loading) {
		//loading = loading ? false : true;
		var load = loading ? 1 : 0;
		if(loading == 2){load = 2;}
		if(HH.ajaxSta==1) return;HH.ajaxSta = 1;
		this.ajax({ url:url,loading:load, method:"POST", body: data } , function(rets) {
			lanYun.ajaxSta = 0;
			callback && callback(rets);
		});
	};

	HH.get = function (url, callback, loading) {
		//loading = loading ? false : true;
		var load = loading ? 1 : 0;
		if(loading == 2){load = 2;}
		if(HH.ajaxSta==1) return;HH.ajaxSta = 1;
		this.ajax({ url:url,loading:load, method:"GET" } , function(rets) {
			lanYun.ajaxSta = 0;
			callback && callback(rets);
		});
	};


})(lanYun);

!(function(HH) {
	// index.html中设置顶部高度适配
	HH.indexSetHeader = function(id) {
		var head = document.getElementById(id);
		return HH.fixStatusBar(head);
	};
	//加载进度动画
	HH.showProgress = function(info){
		if(!HH.UILoading){
			HH.UILoading = api.require('UILoading');
		}
		if(lanYun.loadType == 'icon') {
			var ldparam = {
				rect: {w:100,h:100},
				styles: {interval:30,frame: {w:30,h:30},bg:'rgba(255,255,255,1)'},
				mask:'rgba(255,255,255,1)',
				content: []
			};
			var conimg = [];
			var ldimgpath = info.type && info.type == 2 ? 'icon7' : 'icon8';
			for (var i = 1; i <= 18; i++) {
				conimg.push({frame: 'widget://image/loading/'+ldimgpath+'/'+i+'.PNG'});
			}

			if( info.type && info.type == 2) {
				ldparam.rect = {w:80,h:80};
				ldparam.styles = {interval:30,frame: {w:30,h:30},bg:'rgba(0,0,0,0.6)',corner:8};
				ldparam.mask = 'rgba(0,0,0,0)';
			}

			ldparam.content = conimg;
			HH.UILoading.keyFrame(ldparam);

		}else{
			var parm = { fixed: true, size:40, center: {x: api.winWidth/2.0,y: api.winHeight/2.0} };
			if(info.mask) parm.mask = info.mask;
			HH.UILoading.flower( parm, function(ret) { HH.UILoading_id = ret.id; });
		}
	};
	//隐藏加载动画

	HH.hideProgress = function() {
		if(!HH.UILoading) return;
		if (lanYun.loadType=='icon') {
			//setTimeout(function(){ HH.UILoading.closeKeyFrame(); }, 2000);
			HH.UILoading.closeKeyFrame();
			return;
		}
		HH.UILoading.closeFlower({id:HH.UILoading_id});
	};

	//--------localStorage
	HH.uzStorage = function(){
		var ls = window.localStorage;
		return ls;
	};
	HH.setStorage = function(key, value){
		if(arguments.length === 2){
			var v = value;
			if(typeof v == 'object'){
				v = JSON.stringify(v);
				v = 'obj-'+ v;
			}else{
				v = 'str-'+ v;
			}
			var ls = HH.uzStorage();
			if(ls){
				ls.setItem(key, v);
			}
		}
	};
	HH.isNull = function(obj) {
        if(!obj || typeof(obj) == "undefined" || obj == "" || obj === "undefined") {
            return true;
        }
        return false;
    };
	HH.rmStorage = function(key){
		var ls = HH.uzStorage();
		if(ls && key){
			ls.removeItem(key);
		}
	};
	HH.clStorage = function () {
		var ls = HH.uzStorage();
		ls.clear();
	}
	HH.getStorage = function(key){
		var ls = HH.uzStorage();
		if(ls){
			var v = ls.getItem(key);
			if(!v){
				return false;
			}
			if(v.indexOf('obj-') === 0){
				v = v.slice(4);
				return JSON.parse(v);
			}else if(v.indexOf('str-') === 0){
				return v.slice(4);
			}
		}
	};
	HH.isElement = function(obj){
		return !!(obj && obj.nodeType == 1);
	};
	HH.fixStatusBar = function(el){
		if(!HH.isElement(el)){
			return 0;
		}
		var ls = HH.uzStorage();
		if(ls){
			ls.setItem('topH', api.safeArea.top);
			ls.setItem('bottomH', api.safeArea.bottom);
		}
		el.style.paddingTop = api.safeArea.top + 'px';
		return el.offsetHeight;
	};
	HH.extend = function(a, b) {
		for (var key in b) {
			if (b.hasOwnProperty(key)) {
				a[key] = b[key];
			}
		}
		return a;
	};
	HH.copy = function (data) {
		return JSON.parse(JSON.stringify(data));
	};

	HH.toast = function(msg, wz , time){
		if(!isApp){
			alert(msg);
			return;
		}
		api.toast({ msg:msg, duration:time?time:2000,location:wz?wz:'bottom'});
	};

	HH.alert = function(param, callback){
		param.topFname = api.frameName;
		api.openFrame({
			name: param.fname,
			url: 'widget://html/dialog/alert.html',
			rect: {x:0, y:0,w:'auto',h:'auto'},
			pageParam:param
		});
		window.nowDialogCallback = callback;
	};
	//frame 弹框 by juelie
	HH.dialog = {
		//带输入框
		input : function(param, callback){
			param.topFname = api.frameName;
			api.openFrame({
				name: param.fname,
				url: 'widget://html/dialog/input.html',
				rect: {x:0, y:0,w:'auto',h:'auto'},
				pageParam:param
			});
			window.nowDialogCallback = callback;
		},
		//带输入框大段文字
		inputMore : function(param, callback){
			param.topFname = api.frameName;
			api.openFrame({
				name: param.fname,
				url: 'widget://html/dialog/inputMore.html',
				rect: {x:0, y:0,w:'auto',h:'auto'},
				pageParam:param
			});
			window.nowDialogCallback = callback;
		},
		alert1 : function(param, callback){
			param.topFname = api.frameName;
			api.openFrame({
				name: param.fname,
				url: 'widget://html/dialog/del_botton.html',
				rect: {x:0, y:0,w:'auto',h:'auto'},
				pageParam:param
			});
			window.nowDialogCallback = callback;
		},
		//继续写新的...
	}

	//裁剪
	HH.openCaiQie = function(path,w,h,qua){
		if(!w) w = 80;if(!h) h = 1;
		if(!qua) qua = 0.8;
		api.openFrame({
			name: 'caiqie',
			url: 'widget://html/main/cai.html',
			rect: {x: 0,y: 0,w: 'auto',h: 'auto'},
			pageParam: {wge:w,bili:h,frm:api.frameName,img:path,qua:qua},
			bounces: false,
			bgColor: '#888',
			vScrollBarEnabled: true,
			hScrollBarEnabled: true
		});
	};

	//随机数
	HH.randStr = function(len) {
	　　len = len || 32;
	　　var chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
	　　var maxPos = chars.length;
	　　var pwd = '';
	　　for (i = 0; i < len; i++) {
		　　	pwd += chars.charAt(Math.floor(Math.random() * maxPos));
		}
		return pwd;
	};

	//获取手机权限
	HH.getPermission = function(arr){
		if(!arr)return ;
		var resultList = api.hasPermission({
			list:arr
		});
		var status = resultList ? true : false;
		var requestarr = [];
		if(status){
			$.each(resultList,function(k,v){
				if(!v.granted){
					status = false;
					requestarr.push(v.name);
				}
			});
		}
		if(!status){
			api.requestPermission({
				list:requestarr,
				code:1
			}, function(ret, err){
				console.log(JSON.stringify(ret));
			});
		}
	};

	//获取文件后缀名
	HH.getFileExt = function(filename) {
		var pos = filename.lastIndexOf('.');
		suffix = '';
		if(pos != -1) {
			suffix = filename.substring(pos);
		}
		return suffix;
	};

	//联动选择器
	HH.actionSelect = function(param){
		param = param ? param : {col:3,title:''};
		var data = [];
		//弹出城市选择窗口
		if(param.cachekey){
			data = JSON.parse(localStorage.birthdays) || [];//缓存读取
		}else if(param.data){
			data = param.data;//传数据
		}
		if(!data)return ;
		var UIActionSelector = api.require('UIActionSelector');
		UIActionSelector.open({
			datas:data,
			layout:{row:5,col:param.col,height:30,size:15,sizeActive:15,rowSpacing:5,colSpacing:10,maskBg:'rgba(0,0,0,0.2)',
			bg:'#fff',color:'#999',colorActive:'#333333',colorSelected:'#333333',leftMargin:15,rightMargin:15,},
			animation : true,
			cancel:{text:'取消',size:14,w:50,h:35,bg:'none',bgActive:'none',color:'#333333',colorActive:'#666666'},
			ok : {text:'完成',size:14,w:50,h:35,bg:'none',bgActive:'none',color:'#333333',colorActive:'#666666'},
			title:{text:param.title ? param.title : '',size:15,h:50,bg:'#fff',color:'#444444'}
		}, function(result, err){
			if (result.eventType == 'ok') {
				param && param.successCall(result);
			}
		});
	};


	// 缓存当天日期
	HH.getNewDate = function () {
		var d = new Date();    //根据时间戳生成的时间对象
		var year = d.getFullYear();
		var month = d.getMonth()+1;
		var day = d.getDate();

		var yearIndex = d.getFullYear();
		var monthIndex = d.getMonth();
		var dayIndex = d.getDate()-1;

		month = month < 10 ? "0" + month : month;
		day = day < 10 ? "0" + day : day;
		var s1 = year + "-" + month + "-" + day;
		var s2 = year + "年" + month + "月" + day + "日";
		var s3 = year + "-" + month;
		var s4 = year + "年" + month + "月";
		var data = {};
		data.t1 = s1;
		data.t2 = s2;
		data.t3 = s3;
		data.t4 = s4;

		// 当前索引
		// var dateIndex = [];
		// var arr = JSON.parse(localStorage.birthdays);
		// $.each(arr,function(i, n){
		// 	if(n.name0 == yearIndex){
		// 		dateIndex.push(i);
		// 		return i;
		// 	}
		// });
		// dateIndex.push(monthIndex);
		// dateIndex.push(dayIndex);
		// data.dateIndex = dateIndex;
		HH.setStorage("newDate",data);
		api.setPrefs({
			key: 'birthday_create',
			value: s1
		});
	}

	//时间生成
	HH.getListDate = function(){
		var d = new Date();
		// 今天的日期
		var ye = d.getFullYear();
		var mo = d.getMonth()+1;
		var da = d.getDate();
		mo = mo < 10 ? "0" + mo : mo;
		da = da < 10 ? "0" + da : da;
		var sday = ye + "-" + mo + "-" + da;

		// 明天的日期
		d = d.setDate(d.getDate()+1);
		d = new Date(d);
		var year = d.getFullYear();
		var month = d.getMonth();
		var day = d.getDate();
		var s1 = year + "-" + (month + 1) + "-" + day;

		var prefs_birthday = api.getPrefs({
			sync: true,
			key: 'birthday_create'
		});

		if(prefs_birthday == sday){
			return ;
		}

		// 当前时间
		var date = new Date(year,month,day);
		//var t = date.getTime();
		var year = new Date(2021,00,00,00,00,00).getTime();

		//year = t-year;
		//var x = t-year;//n为第2个框输入的年数,（天：x=t+(24*60*60*1000*n);

		var dold = new Date();
		dold.setTime(year);
		s1 = new Date(s1.replace(/-/g, "/"));
		var s2 = new Date(dold);
		var days = s1.getTime() - s2;
		var daynum = parseInt(days / (1000 * 60 * 60 * 24));
		var _days = [];

		for(var i=1;i < daynum;i++){
			var _day3 = new Date();
			_day3.setTime(d-(24*60*60*1000*i));
			var day3 = new Date(_day3);
			var obj = [];
			var yue = day3.getMonth()+1;
			var tian = day3.getDate();
			obj.push(day3.getFullYear());
			obj.push(yue);
			obj.push(tian);
			_days.push(obj);
		}
		_days.reverse();
		var redsys = {};
		for(var i=0;i < _days.length;i++){
			var item = _days[i];
			redsys[item[0]] = redsys[item[0]] ? redsys[item[0]] : {};
			redsys[item[0]][item[1]] = redsys[item[0]][item[1]] ? redsys[item[0]][item[1]] : [];
			redsys[item[0]][item[1]].push(item[2]);
		}
		//console.log(JSON.stringify(redsys));
		var result = [];
		$.each(redsys,function(key,item){
			var one = [];
			$.each(item,function(okey,oitem){
				var two = [];
				$.each(oitem,function(tkey,titem){
					if(titem < 10){titem = '0'+ titem;}
					two.push({name:titem + "日",name0:titem,index:tkey});
				});
				if(okey < 10){okey = '0'+ okey;}
				one.push({name:okey + "月",name0:okey,index:okey,sub:two});
			});
			result.unshift({name:key + "年",name0:key,index:key,sub:one});
		});

		// api.setPrefs({
		// 	key: 'birthday_create',
		// 	value:year+'-'+month+'-'+day
		// });

		//console.log(JSON.stringify(result));
		localStorage.birthdays = JSON.stringify(result);

		// 获取当天时间参数
		HH.getNewDate();

	}

	//生成生日的数据
	HH.bithdays = function(){
		var d = new Date();    //根据时间戳生成的时间对象
		var year = d.getFullYear();
		var month = d.getMonth();
		var day = d.getDate();
		var s1 = year + "-" + (month + 1) + "-" + day;

		var prefs_birthday = api.getPrefs({
			sync: true,
			key: 'birthday_create'
		});

		if(prefs_birthday == (year+'-'+month+'-'+day)){
			return ;
		}

		var date = new Date(year,month,day);//转换标准日期类型
		var t = date.getTime();

		var year100 = (24*60*60*1000*365*100);
		var x=t-year100;//n为第2个框输入的年数,（天：x=t+(24*60*60*1000*n);

		var dold = new Date();
		dold.setTime(x);

		s1 = new Date(s1.replace(/-/g, "/"));
		var s2 = new Date(dold);
		var days = s1.getTime() - s2;
		var daynum = parseInt(days / (1000 * 60 * 60 * 24));

		var _days = [];
		for(var i=1;i < daynum;i++){
			var _day3 = new Date();
			_day3.setTime(d-(24*60*60*1000*i));
			var day3 = new Date(_day3);
			var obj = [];
			obj.push(day3.getFullYear());
			obj.push((day3.getMonth()+1));
			obj.push(day3.getDate());
			_days.push(obj);
		}
		_days.reverse();

		var redsys = {};
		for(var i=0;i < _days.length;i++){
			var item = _days[i];
			redsys[item[0]] = redsys[item[0]] ? redsys[item[0]] : {};
			redsys[item[0]][item[1]] = redsys[item[0]][item[1]] ? redsys[item[0]][item[1]] : [];
			redsys[item[0]][item[1]].push(item[2]);
		}

		var result = [];
		$.each(redsys,function(key,item){
			var one = [];
			$.each(item,function(okey,oitem){
				var two = [];
				$.each(oitem,function(tkey,titem){
					two.push({name:titem});
				});
				one.push({name:okey,sub:two});
			});
			result.push({name:key,sub:one});
		});

		api.setPrefs({
			key: 'birthday_create',
			value:year+'-'+month+'-'+day
		});
		localStorage.birthdays = JSON.stringify(result);
	}

})(lanYun);

// app
!(function(HH) {
	HH.frameGroup = {
		group:[],
		open:function(Param) {
			var data = Param.data;
			var fname = null;
			for (var i = 0; i <= data.length-1; i++) {
				fname = 'main'+i;
				var rect = {x: 0, w:'auto',y: data[i].y, h: data[i].h, xy:data[i].xy, xh:data[i].xh };
				this.group.push(rect);
				api.openFrame({
					name:fname ,url:data[i].url,
					rect:rect,
					vScrollBarEnabled:data[i].Scroll,
					pageParam: data[i].Param,
					bounces: data[i].tan,
					bgColor:'#eee',
					hScrollBarEnabled: false
				});
			}
			lanYun.frameGroup.show(0);
			api.bringFrameToFront({from: 'main'+Param.index});
		},
		show:function(id){
			var tis = this.group[id];
			for (var i = 0; i <= this.group.length-1; i++) {
				if(i == id){
					var rec = {x:0,w:'auto',y:tis.y,h:tis.h};
					if(typeof tis.xy != "undefined") rec.y = tis.xy;
					if(tis.xh) rec.h = tis.xh;
					api.setFrameAttr({name: 'main'+i, rect:rec });
				}else{
					api.setFrameAttr({name: 'main'+i, rect:tis});
				}
			}
			api.bringFrameToFront({from: 'main'+id});
		}
	};

	// HH.db = {
	// 	dbname:'lyDB',
	// 	coon:api.require('db'),
	// 	open:function () {
	// 		//var db = api.require('db');
	// 		var pram = { name: this.dbname };
	// 		var retfun = function(ret, err) {
	// 			if (ret.status) {
	// 				lanYun.db = true;
	// 			}
	// 		};
	// 		if(HH.dbSync){
	// 			var res = this.coon.openDatabaseSync(pram);
	// 			if(res.status){
	// 				//this.delTable('msgs');
	// 				//this.addTable('msgs');
	// 			}
	// 		}else{
	// 			this.coon.openDatabase(pram, retfun);
	// 		}
	// 	},
	// 	clearTable:function (table) {
	// 		var res = this.coon.executeSqlSync({
	// 			name: this.dbname,
	// 			sql: 'DELETE FROM '+table+''
	// 		});
	// 	},
	// 	delTable:function (table) {
	// 		var res = this.coon.executeSqlSync({
	// 			name: this.dbname,
	// 			sql: 'DROP TABLE '+table+''
	// 		});
	// 		//log(res);
	// 	},
	// 	addTable:function (table) {
	// 		var res = this.coon.executeSqlSync({
	// 			name: this.dbname,
	// 			sql: 'CREATE TABLE '+table+'(id int,room varchar(100),isgl int, lv int, nick varchar(50), msg text)'
	// 		});
	// 		//log(res);
	// 	},
	// 	select:function (table, id) {
	// 		var ret = this.coon.selectSqlSync({
	// 		    name: this.dbname, sql: 'SELECT * FROM msgs WHERE room = '+id+' ORDER BY id ASC'
	// 		});
	// 		return ret.data;
	// 	},
	// 	addmsg:function (table, room , data) {
	// 		var sql = 'INSERT INTO '+table+'';
	// 		var key = [];
	// 		var val = ''+room+'';
	// 		for(index in data){
	// 			key.push(index);
	// 			val +=',"'+data[index]+'"';
	// 		}
	// 		sql += '(room,'+key.join(',')+') VALUES ('+ val +')';
	// 		console.log(sql);
	// 		var res = this.coon.executeSqlSync({
	// 		    name: this.dbname,
	// 		    sql: sql
	// 		});
	// 		log(res);
	// 	},
	//
	// };

})(lanYun);
